import axios from "axios"
export default {
    namespaced: true,
    state: {
        list: [
            { _id: 1, name: "张三", age: "20", gender: "男", position: "门店管理员" ,phoneNumber:"11111111111"},
            { _id: 2, name: "李四", age: "30", gender: "女", position: "门店管理员",phoneNumber:"22222222222" }
        ],
        findlist1: {}
    },
    getters: {
        finding: function (state, playload) {
            let { type, value } = state.findlist1
            let newarr = state.list
            // 判断搜索条件是否输入
            if (value) {
                return newarr.filter(item => item[type].includes(value))
            }
            return state.list

        }
    },
    mutations: {
        // 将查询条件放入厂库
        finders: function (state, playload) {

            state.findlist1 = playload
        },

    },
    actions: {

        // 渲染列表
        getuser: function (context) {
            axios.get("/api/userlist/get_userlist").then(res => {
                context.state.list = res.data
            })
        },
        //    删除列表
        removeuser: function (context, payload) {
            
            axios.post("/api/userlist/remove_userlist", payload).then(res => {
 
            })
        },

        //    修改列表
        updateuser: function (context, payload) {
            axios.post("/api/userlist/update_userlist", payload).then(res => {
               
            })
        },
    }





}